﻿using Elasticsearch.Net;
using Microsoft.Extensions.Configuration;
using Nest;
using VisionCloud.Utility.Security;

namespace VisionCloud.Utility.ElasticSearch
{
    /// <summary>
    /// 自定义的ElasticClient
    /// </summary>
    public class DefaultElasticClient : ElasticClient
    {
        /// <summary>
        /// 带连接池的ElasticClient
        /// </summary>
        /// <param name="connectionPool"></param>
        public DefaultElasticClient(IConnectionPool connectionPool, IConfiguration cfg)
            : base(new ConnectionSettings(connectionPool).BasicAuthentication(AesCoreHelper.Decrypt(cfg["NLog:UserName"], AesCoreHelper.Sceret),
                AesCoreHelper.Decrypt(cfg["NLog:PassWord"], AesCoreHelper.Sceret)))
        { }
    }
}